package canglang.monitor.user.service.impl;

import java.util.List;

import canglang.monitor.core.base.pagination.PaginatedListHelper;
import canglang.monitor.user.dao.UserDAO;
import canglang.monitor.user.model.UserModel;
import canglang.monitor.user.service.UserMgr;
import canglang.monitor.user.to.SearchTO;



@SuppressWarnings("unchecked")
public class UserMgrImpl implements UserMgr {
	private UserDAO userDAO;

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	public PaginatedListHelper search(PaginatedListHelper helper,
			SearchTO searchTO) {
		int count = userDAO.searchCount(searchTO);
		helper.setFullListSize(count);
		List list = userDAO.searchList(helper, searchTO);
		helper.setList(list);
		return helper;
	}

	public UserModel addUser(UserModel userModel) {
		userDAO.addUser(userModel);
		return userDAO.getUser(userModel.getUserId());
	}

	public UserModel getUser(String userId) {
		return userDAO.getUser(userId);
	}

	public UserModel saveUser(UserModel userModel) {
		userDAO.saveUser(userModel);
		return userDAO.getUser(userModel.getUserId());
	}

	public void deleteUser(String userId) {
		userDAO.deleteUser(userId);
	}
	
}
